<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* function* test() {
        console.log("第一次运行");
        yield 1;
        console.log("第二次运行");
        yield 2;
        console.log("第三次运行");
        return 10; // 第一次调用return的next的返回值才有效
      }

      const generator = test(); */

      function* test() {
        let info = yield 1;
        console.log(info);
        info = yield 2 + info;
        console.log(info);
      }

      const generator = test();
    </script>
  </body>
</html>
